import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path'
// import {fileURLToPath} from 'url'
import Unocss from 'unocss/vite'
import * as path from "node:path";
import Components from 'unplugin-vue-components/vite'

// const currentDir = fileURLToPath(new URL('.', import.meta.url))
// const currentDir = path.resolve(__dirname, 'src')
// console.log('currentDir',currentDir)
console.log(path.resolve(__dirname, './src/common/var.scss'));
export default defineConfig({
    plugins: [
        vue(),
        Unocss(),
        Components({
            dts: true,
            resolvers: [
                (componentName) => {
                    // where `componentName` is always CapitalCase
                    if (componentName.startsWith('V'))
                        return { name: componentName, from: '@vue3-lib/components' }
                },
            ],
        })
    ],
    resolve: {
        alias: {
            '@': resolve(__dirname, './src')
        }
    },
    css: {
        preprocessorOptions: {
            scss: {
                // additionalData: `@use "@/common/var.scss" as *;`,
                api: 'modern-compiler',
                // importers: [
                //     path.resolve(__dirname, './src/common/var.scss')
                // ]
            },
        },
    },
    server: {
        port: 5173,
        host: true,
        open: true
    }
})